package com.dpiinc.TechPage.room.dao

import androidx.room.*
import com.dpiinc.TechPage.room.bean.LabelEntity

@Dao
interface LabelDao {
    @Insert(onConflict = OnConflictStrategy.REPLACE)
    fun insert(label: LabelEntity)

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    fun insert(labels: List<LabelEntity>)

    @Query("SELECT * FROM labels ORDER BY id ASC")
//    fun getLabels(): DataSource.Factory<Int, NoteEntity>
//    fun getLabels(): LiveData<List<LabelEntity>>
    fun getLabels(): List<LabelEntity>

    @Query("SELECT * FROM labels WHERE id = :id ")
    fun getLabel(id: String): LabelEntity


    @Query("SELECT * FROM labels WHERE content = :content ")
    fun getLabelByContent(content: String): LabelEntity

    @Update
    fun update(label: LabelEntity)

    @Delete
    fun delete(label: LabelEntity)

    @Query("DELETE FROM labels")
    fun deleteAll()

}